//
// Created by steven on 2017/2/28.
// Copyright (c) 2017 steven. All rights reserved.
//

#import "GMAddSNCarViewController.h"

@interface GMAddSNCarViewController()

@property (nonatomic, strong)UITextField *SNTextField;

@end

@implementation GMAddSNCarViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self setupMainView];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    UIBarButtonItem *saveBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(saveBarButtonPressed)];
    self.navigationItem.rightBarButtonItem = saveBarButtonItem;
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    CALayer *bottomLayer = [[CALayer alloc] init];
    bottomLayer.borderColor = BUTTON_ACTIVE_COLOR.CGColor;
    bottomLayer.borderWidth = 1;
    bottomLayer.frame = CGRectMake(0, self.SNTextField.frame.size.height, self.SNTextField.frame.size.width, 1);
    [self.SNTextField.layer addSublayer:bottomLayer];
}

- (void)setupMainView {
    self.navigationItem.title = @"输入设备编号";

    [self.view addSubview:self.SNTextField];
    [self.SNTextField autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:40];
    [self.SNTextField autoPinEdgeToSuperviewEdge:ALEdgeLeading withInset:20];
    [self.SNTextField autoPinEdgeToSuperviewEdge:ALEdgeTrailing withInset:20];
}

#pragma mark - save barButton pressed
- (void)saveBarButtonPressed {

}

#pragma mark - nickName text field
- (UITextField *)SNTextField {
    if (!_SNTextField) {
        _SNTextField = [[UITextField alloc] init];
        _SNTextField.placeholder = @"请输入设备编号";
    }

    return _SNTextField;
}
@end